﻿using System;
using WiMo.Games;
using WiMo.Games.Audio;
using System.Runtime.InteropServices;
using System.Threading;

namespace WiMo.Games.WM5
{
    public class GameAudio : IGameAudio
    {
        System.Media.SoundPlayer _sound;

        public void Load(IContentManager contentManager, string name)
        {
            if (!name.ToLower().EndsWith(".wav"))
                name += ".wav";

            var fileName = contentManager.GetFullPath(name);

            Volume = 1.0f;

            _sound = new System.Media.SoundPlayer(fileName);
        }

        public void Play()
        {
            //_sound.Stop();
            //_sound.Play();
        }

        public void Pause()
        {
            throw new NotImplementedException();
        }

        public float Volume
        {
            get;
            set;
        }

        public void Stop()
        {
            throw new NotImplementedException();
        }

        public object AudioInformation { get; set; }

        public void Dispose()
        {
            if (_sound != null)
                _sound.Dispose();

            var disposable = AudioInformation as IDisposable;
            if (disposable != null)
                disposable.Dispose();
        }
    }
}
